package YanghuiTriangle;


import java.util.ArrayList;
import java.util.List;

class Solution {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> list = new ArrayList<>();
        list.add(1);
        ret.add(list);
        for (int i = 1; i < numRows; i++) {
            List<Integer> curRow = new ArrayList<>();
            curRow.add(1);
            List<Integer> preRow = ret.get(i - 1);
            for (int j = 1; j < i; j++) {
                int num = preRow.get(j) + preRow.get(j - 1);
                curRow.add(num);
            }
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }


}

public class Test {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.generate(5);
        System.out.println(solution.generate(5));
    }



}
